#include <iostream>
#include <vector>

#include <omp.h>

int main(int argc, char** argv)
{
    const int iDimension = 234562586;
    double *A = new double[iDimension];
    double *B = new double[iDimension];
    double *C = new double[iDimension];

    std::cout<< "Max number of threads = " << omp_get_num_threads() << std::endl;
    omp_set_num_threads(10);
    std::cout<< "Current number of threads = " << omp_get_num_threads() << std::endl;

#pragma omp parallel for schedule(static) // static dynamic guided
    for(int i=0; i<iDimension; i++)
    {
        A[i] = 0.0;
        B[i] = 1.0;
        C[i] = 2.0;
    }

    double t1 = omp_get_wtime();

#pragma omp parallel
    {
#pragma omp single
        {
            std::cout << "Number of threads = " << omp_get_num_threads() << std::endl;
            fflush(stdout);
        }

#pragma omp for
        for(int i=0; i<iDimension; i++)
        {
            A[i] = B[i] + C[i];
        }
    }

    double t2 = omp_get_wtime();

    std::cout << "Duration time = " << t2-t1 << "seconds" << std::endl;

    delete[] A;
    delete[] B;
    delete[] C;

    return 0;
}
